home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d12
/
cbibcode.arc
/
STRTOK.C
< prev
next >
Wrap
Text File
|
1991-08-05
|
623b
|
22 lines
/* strtok.c From TC Bible page 301 Use strtok to get the next token, or
substring, in a string delimited by any character from a second string */
#include <stdio.h>
#include <string.h>
char tokensep[] = " \t,";
main()
{
int i = 0;
char buf[80], *token;
printf("Enter a string of tokens separated by comma or blank: ");
gets(buf);
token = strtok(buf, tokensep); /* Call strtok once to get first
token and initialize it */
while(token != NULL) /* Keep calling strtok to get all tokens */
{
i++;
printf("Token %d = %s\n", i, token);
token = strtok(NULL, tokensep);
}
}